//
//  ManagePasscode.m
//  KurtulusLaw
//
//  Created by phuc phuc on 12/4/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ManagePasscode.h"
#import "PasscodeViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "Constant.h"

@interface ManagePasscode()
{
	UIButton *btnBack;
	
}
@end

@implementation ManagePasscode
@synthesize btnTurnOff;
@synthesize btnChangePasscode;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle
-(void)back:(id)sender
{
    [self dismissModalViewControllerAnimated:YES];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = NSLocalizedString(@"Passcode",nil);
	[self.btnTurnOff setTitle: NSLocalizedString(@"Turn Passcode Off", nil) forState:UIControlStateNormal];
	[self.btnChangePasscode setTitle:NSLocalizedString(@"Change Passcode", nil) forState:UIControlStateNormal];
	
    btnBack = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 41, 48)];
    btnBack.tintColor = [UIColor blackColor];
    [btnBack setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    [btnBack setImage:[UIImage imageNamed:kImageSetting34x46] forState:UIControlStateNormal];
    [btnBack addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
	btnBack.layer.borderWidth = 0;
    //self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnBack];
	
	
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav-bg-black"] forBarMetrics:UIBarMetricsDefault] ;
}
-(void)viewWillAppear:(BOOL)animated
{
	[super viewWillAppear:animated];
	[self.navigationController.navigationBar addSubview:btnBack];
    
}
-(void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
	[btnBack removeFromSuperview];
    
}

- (void)viewDidUnload
{
	[self setBtnTurnOff:nil];
	[self setBtnChangePasscode:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)turnOff:(id)sender {
    PasscodeViewController *passcode = [[PasscodeViewController alloc] init];
    passcode.isChangePasscode = NO;
	self.title = @"";
    [self.navigationController pushViewController:passcode animated:YES];
    
}

- (IBAction)changeCode:(id)sender {
    PasscodeViewController *passcode = [[PasscodeViewController alloc] init];
	passcode.isChangePasscode = YES;
    self.title = @"";
    [self.navigationController pushViewController:passcode animated:YES];

    
}
@end
